package com.github.chirspan.xaas.core.constant;

/**
 * @author ChenPan
 * @date 2018/6/22 18:37
 * description:
 */
public interface SecurityConstants {

    /**
     * 标志
     */
    String FROM = "from";

    /**
     * 授权
     */
    String AUTHORIZATION = "Authorization";

    /**
     * Bearer token
     */
    String BEARER = "Bearer";

    /**
     * token key
     */
    String TOKEN_KEY = "token";

    /**
     * clinet授权模式
     */
    String BASIC = "Basic ";

    /**
     * 授权码模式
     */
    String AUTHORIZATION_CODE = "authorization_code";

    /**
     * 密码模式
     */
    String PASSWORD = "password";

    /**
     * 刷新token
     */
    String REFRESH_TOKEN = "refresh_token";

    /**
     * oauth token
     */
    String OAUTH_TOKEN_URL = "/oauth/token";

    String CHECK_TOKEN_URL = "/oauth/check_token";

    String AUTH_BASE_URL = "/auth/";

    String API_DOC_URL = "/v2/api-docs";

    /**
     * 手机登录URL
     */
    String MOBILE_TOKEN_URL = "/mobile/token";

    /**
     * JWT 用户对象key
     */
    String JWT_USER_NAME = "user_name";

    String JWT_USER_ID = "user_id";

    /**
     * JWT 用户权限
     */
    String JWT_USER_AUTHORITIES = "authorities";

    /**
     * Client
     */
    String JWT_CLIENT = "client_id";

    /**
     * 默认的处理验证码的url前缀
     */
    String DEFAULT_VALIDATE_CODE_URL_PREFIX = "/code";

    /**
     * 手机号的处理验证码的url前缀
     */
    String MOBILE_VALIDATE_CODE_URL_PREFIX = "/smsCode";

    /**
     * 默认保存code的前缀
     */
    String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY";

    /**
     * Token-AuthUser
     */
    String TOKEN_USER_DETAIL = "token-user-detail";

    /**
     * 前缀
     */
    String PREFIX = "xaas.auth.token";

    /**
     * 用户信息头
     */
    String USER_HEADER = "x-user-header";

    String USER_ID_HEADER = "x-user-id-header";

    /**
     * 角色信息头
     */
    String ROLE_HEADER = "x-role-header";

    /**
     * 客户端信息头
     */
    String CLIENT_HEADER = "x-client-header";


    /***
     * 资源服务器默认bean名称
     */
    String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";

    String CLIENT_TABLE = "xaas_rbac_oauth_client_details";

    /**
     * sys_oauth_client_details 表的字段
     */
    String CLIENT_FIELDS = "client_id, client_secret as client_secret, resource_ids, scope, "
            + "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
            + "refresh_token_validity, additional_information, autoapprove";

    /**
     * JdbcClientDetailsService 查询语句
     */
    String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS
            + " from " + CLIENT_TABLE;

    /**
     * 默认的查询语句
     */
    String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id";

    /**
     * 按条件client_id 查询
     */
    String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ?";
}
